package com.veer.shop.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 邮件相关工具类
 * 
 * @author WangBin
 * 2021年1月3日-上午11:50:51
 */
public class MailUtil {
	
	/**
	 * 校验邮箱地址合法性
	 * 
	 * @param email
	 * @return
	 */
	public static Boolean verify(String email) {
		Boolean flag = false;
	    try {
	        String check = "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
	        Pattern regex = Pattern.compile(check);
	        Matcher matcher = regex.matcher(email);
	        flag = matcher.matches();
	    } catch (Exception e) {
	        flag = false;
	    }
	    return flag;
	}
}
